/*
 * ProhraShowPanel.java
 * 
 * Created on 5.12.2007, 18:43:59
 * 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cz.possoft.client.gui.panel.nastavenispodnipanel.panel;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;

import layout.TableLayout;
import cz.possoft.client.gui.dialog.SimpleDialog;
import cz.possoft.client.gui.panel.nastavenispodnipanel.components.ExceptionPanel;
import cz.possoft.client.utils.PanelHolderUtils;
import cz.possoft.messages.PropertiesManager;
import cz.possoft.messages.Text;

/**
 *
 * @author mara
 */
public class ProhraShowPanel extends JPanel {

    double size[][] =
        {{50,40,70,40,50},
        {32,32,32,32,32,32,32,32,32,32,32}};
    
    private JButton yesButton;    
    private static ExceptionPanel connectExceptionText;
    
    public ProhraShowPanel() {
        setLayout(new TableLayout(size));         
        initContents();
    }
    
    public void initContents() {
        JLabel label = new JLabel(PropertiesManager.getInstance().getMessageForKey(Text.PROHRA_NAVRH));
        label.setHorizontalAlignment(JLabel.CENTER);
        add(label, "0,1,4,1");
        yesButton = new JButton(PropertiesManager.getInstance().getMessageForKey(Text.YES));
        yesButton.addActionListener(new YesButtonListener());        
        add(yesButton, "2,3");
//        connectExceptionText = new ExceptionPanel("");
//        add(connectExceptionText, "1,8,4,8");
    }
    
    private class YesButtonListener implements ActionListener {
        
        // nastava po stisku tlacitka YES
        public void actionPerformed(ActionEvent ae) {
//            connectExceptionText.setText(Text.WAIT_FOR_OPPONENT);
            NastaveniShowPanel.getConnectThread().sendToServer("PROHRA_NAVRH: ");
            PanelHolderUtils.getCurrentGamePanel().setActiveToGame(false);
            PanelHolderUtils.getCurrentGamePanel().setEndStateToGame(true);
            SimpleDialog.getInstance(PropertiesManager.getInstance().getMessageForKey(Text.PROHRA), PropertiesManager.getInstance().getMessageForKey(Text.VZDAL_PROHRA_MESSAGE));
        }
    }

}
